package com.redsoil.house.widget.bottombar;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;

import com.redsoil.house.R;
import com.zhy.autolayout.AutoLinearLayout;

/**
 * Created by weidingqiang on 2018/12/19.
 */

public class MatterBottomBarItem extends AutoLinearLayout {

    private ImageView mIcon;

    private TextView mTvTitle;

    public MatterBottomBarItem(Context context) {
        this(context,null);
    }

    public MatterBottomBarItem(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MatterBottomBarItem);

        Drawable icon = typedArray.getDrawable(R.styleable.MatterBottomBarItem_matter_Icon);
        String text = typedArray.getString(R.styleable.MatterBottomBarItem_matter_Text);

        typedArray.recycle();

        LayoutInflater inflater = LayoutInflater.from(context);
        inflater.inflate(R.layout.matter_bottom_bar_item, this, true);

        mIcon = (ImageView) this.findViewById(R.id.mIcon);
        mTvTitle = (TextView) this.findViewById(R.id.mTvTitle);

        mIcon.setImageDrawable(icon);
        mTvTitle.setText(text);

    }
}
